﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;

namespace LabMS.Web.Equipment.Consum
{
    public partial class consumstatistics : Base.BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            strPagePrivilege.Add("HCTJ");
            strPageUserType.Add("mana");

            if (!Page.IsPostBack)
            {
                bind("");
                bindddl();
            }
        }

        public void bindddl()
        {
            //LabMS.BLL.Lab blab = new LabMS.BLL.Lab();
            //List<LabMS.Model.Lab> mLab = new List<LabMS.Model.Lab>();
            //mLab = blab.GetModelList(" Lab_ParentID is null ");
            //ddlWarehouse.DataSource = mLab;
            //ddlWarehouse.DataTextField = "Lab_Name";
            //ddlWarehouse.DataValueField = "Lab_Code";
            //ddlWarehouse.DataBind();
            //ddlWarehouse.Items.Insert(0, new ListItem("", "null"));
            ;
        }

        public void bind(string strWhere)
        {
            List<ExtendModule.InstrumentAndConsumables> listeconsummodule = new
                List<ExtendModule.InstrumentAndConsumables>();
            ExtendBLL.InstrumentAndConsumables beconsum = new ExtendBLL.InstrumentAndConsumables();
            listeconsummodule = beconsum.GetExtendStatisticsModelList(" Type = 'xiaohaopin' " + strWhere);
            GridViewCStatistics.DataSource = listeconsummodule;
            GridViewCStatistics.DataBind();
        }

        protected void GridViewCStatistics_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            GridViewCStatistics.PageIndex = e.NewPageIndex;
            if (tbLocation.Text.Trim().Equals("") && tbName.Text.Trim().Equals(""))
            {
                bind("");
            }
            else
            {
                string strWhere = "and 1=1 ";
                if (tbLocation.Text.Trim() == "")
                {
                    tbLocationCode.Text = "";
                }
                if (!tbLocationCode.Text.Equals(""))
                {
                    strWhere += " and  StockLocation = '" + tbLocationCode.Text + "'";
                }

                strWhere += " and c.Name like '%" + tbName.Text.Trim() + "%' ";
                bind(strWhere);
            }
        }

        protected void GridViewCStatistics_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            //if (e.Row.RowType == DataControlRowType.DataRow)
            //{
            //    e.Row.Attributes.Add("OnMouseOut", "this.style.backgroundColor='White';this.style.color='#003399'");
            //    e.Row.Attributes.Add("OnMouseOver", "this.style.backgroundColor='#6699FF';this.style.color='#8C4510'");
            //    e.Row.Attributes["style"] = "Cursor:pointer";
                
            //}
        }


        protected void btnSearch_Click(object sender, EventArgs e)
        {
            string strWhere = " and 1=1 ";
            if (tbLocation.Text.Trim() == "")
            {
                tbLocationCode.Text = "";
            }
            if (!tbLocationCode.Text.Equals(""))
            {
                strWhere += " and  StockLocation = '" + tbLocationCode.Text + "'";
            }

            strWhere += " and c.Name like '%" + tbName.Text.Trim() + "%' ";
            bind(strWhere);
        }
    }
}
